import mysql.connector
'''
acid
    -atomicity 原子性  不可分割性  事务
    -consistency 一致性
    -isolation 隔离性
    -duration 持久性
'''
mydb = mysql.connector.connect(
    host='localhost',
    user='root',
    password='',
    database='mydatabase'
)

cursor = mydb.cursor()

# 插入数据
# cursor.execute('insert into user(name,age) values("%s",%d)'%("Mike",18))
# cursor.execute('insert into user(name,age) values(%s,%s)',("Mike",18))

# 删除
# cursor.execute('delete from user where name=%s',('Mike',))

# 修改
# cursor.execute('update user set age=%s where name=%s',(16,'Julia'))

# 提交
mydb.commit()

# 查询
cursor.execute('select * from user')
# 接收返回结果
result = cursor.fetchall()
print(result)


# 关闭
cursor.close()
mydb.close()